package globals;

import java.util.HashMap;
import java.util.Map;

public class SystemGeneralState {
	private static SystemGeneralState instance = null;
	private Map<String, String> generalVariables;
	
	protected SystemGeneralState() {
		// Exists only to defeat instantiation
		generalVariables = new HashMap<String, String>();
	}

	/*
	 * There are several interesting points concerning the ClassicSingleton
	 * class. First, ClassicSingleton employs a technique known as lazy
	 * instantiation to create the singleton; as a result, the singleton
	 * instance is not created until the getInstance() method is called for the
	 * first time. This technique ensures that singleton instances are created
	 * only when needed.
	 */
	public static SystemGeneralState getInstance() {
		if (instance == null) {
			instance = new SystemGeneralState();
		}

		return instance;
	}

	/**
	 * @return the generalVariables
	 */
	public Map<String, String> getGeneralVariables() {
		return generalVariables;
	}
	
	public void put(String key, String value) {
		generalVariables.put(key, value);
	}
	
	public void remove(String key) {
		generalVariables.remove(key);
	}
	
	public void clear() {
		generalVariables.clear();
	}
	
	public String get(String key) {
		return generalVariables.get(key);
	}
}
